package javango.forms.widgets;

import java.util.HashMap;
import java.util.Map;

import javango.forms.fields.ChoiceField;

public abstract class BaseChoicesWidget extends WidgetBase implements ChoicesWidget {

	public BaseChoicesWidget(Map<String, Object> attrs) {
		super(attrs);
	}

	private ChoiceField field;
	private Map<String, Object> choices;
	
	protected Map<String, Object> getMyChoices() {
		if (choices != null) {
			return choices;
		}
		if (field != null) {
			return field.getChoices();
		}
		return new HashMap<String, Object>();
	}
	
	public ChoiceField getField() {
		return field;
	}

	public void setField(ChoiceField field) {
		this.field = field;
	}

	public Map<String, Object> getChoices() {
		return choices;
	}

	public void setChoices(Map<String, Object> choices) {
		this.choices = choices;
	}

}
